﻿@namespace MudBlazor.Docs.Examples

<MudChart ChartType="ChartType.Donut" LegendPosition="@LegendPosition" Width="300px" Height="300px"
          InputData="@data" InputLabels="@labels">
</MudChart>


<MudSelect Label="Legend Position" Variant="Variant.Outlined" Dense="true" T="@Position" ValueChanged="OnSelectedValue" Class="mt-4">
    <MudSelectItem T="Position" Value="Position.Top">Top</MudSelectItem>
    <MudSelectItem T="Position" Value="Position.Left">Left</MudSelectItem>
    <MudSelectItem T="Position" Value="Position.Right">Right</MudSelectItem>
    <MudSelectItem T="Position" Value="Position.Bottom">Bottom</MudSelectItem>
    <MudSelectItem T="Position" Value="Position.Start">Start</MudSelectItem>
    <MudSelectItem T="Position" Value="Position.End">End</MudSelectItem>
</MudSelect>

@code {
    public double[] data = { 25, 77, 28, 5 };
    public string[] labels = { "Oil", "Coal", "Gas", "Biomass" };

    public Position LegendPosition { get; set; } = Position.Bottom;

    private void OnSelectedValue(Position value)
    {
        switch(value)
        {
            case Position.Top:
                LegendPosition = Position.Top;
                break;
            case Position.Left:
                LegendPosition = Position.Left;
                break;
            case Position.Right:
                LegendPosition = Position.Right;
                break;
            case Position.Bottom:
                LegendPosition = Position.Bottom;
                break;
            case Position.Start:
                LegendPosition = Position.Start;
                break;
            case Position.End:
                LegendPosition = Position.End;
                break;
        }
    }
}